﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid;
using OnOne.Lib;
using OnOne.Data;

namespace PDV
{
  public partial class fMain : OnOne.Forms.fModel01
  {
    private TConection _tconnection;
    private OnOne.Data.ADO Server  = new ADO();
    
    public fMain()
    {
      InitializeComponent();
      SetComponents();
      DBConect();
    }

    private void DBConect()
    {
      _tconnection._eProviders = eProviders.pFirebird;
      _tconnection.sDataBase = @"D:\PROJETOS\Dados\Firebird\2010\SAM\1.0\SAM.FDB";
      _tconnection.sServer = "localhost";
      _tconnection.sUserID = "SYSDBA";
      _tconnection.sPasswd = "masterkey";

      /*      uniConnection1.Provider = "FirebirdClient";}
      uniConnection1.DataSource = "localhost";
      uniConnection1.Database = _tconnection.sDataBase;
      uniConnection1.UserId = _tconnection.sUserID;
      uniConnection1.Password = _tconnection.sPasswd;
      uniConnection1.Port = 3050;
      uniConnection1.Open();
      */
      Server._tconnection = _tconnection;
      Server.DBConect();
      gridControl1.DataSource = Server.DBRequery("SELECT * FROM TBL_PED_ITENS").Tables[0];

    }

    // ----------> Monta Componentes - 1/27/2012 19:27:09 <----------
    private void SetComponents()
    {
      int imax = 5;
      int i;
      String[] scap =  {"COD", "PRODUTO / SERVICO",  "REFERENCIA",  "QTDE",  "UNIT",  "TOTAL"};
      String[] aflds = { "PROD_ID", "ITEM_NOME", "PROD_ID", "ITEM_QTDE", "ITEM_UNIT", "ITEM_TOTAL" };
      int[] iwidth = { 10, 200, 100, 50, 50, 50 };
      GridColumn[] acoluna = new GridColumn[imax];

      for (i = 0; i < imax; i++)
        acoluna[i] = new GridColumn();
      
      for (i = 0; i < imax; i++)
      {
        acoluna[i].Caption = scap[i];
        acoluna[i].Width = iwidth[i];
        acoluna[i].FieldName = aflds[i];
        acoluna[i].Name = "Column" + i.ToString();
        acoluna[i].Visible = true;
        acoluna[i].VisibleIndex = i;
      }

      this.gridView1.Columns.AddRange(acoluna);
      this.gridView1.OptionsView.ShowGroupPanel = false;

      // ----------> Configuracoes do Form - 1/27/2012 22:14:12 <----------
      this.StartPosition = FormStartPosition.CenterScreen;
      this.FormBorderStyle = FormBorderStyle.FixedDialog;


    }

    private void fMain_Load(object sender, EventArgs e)
    {
      
    }

    private void simpleButton7_Click(object sender, EventArgs e)
    {

    }

    private void simpleButton7_KeyDown(object sender, KeyEventArgs e)
    {
      switch (e)
      {
          
      }
    }



  }
}
